#!/bin/sh
#
#
#   Description :
#     altera bourne script for the Design Manager.  This script is called during
#     command line invocation (i.e. /<maxplus2 path>/mentor/max2/max2_dmgr) and is used to set the
#     userware search path and set the toolbox search path after invoking
#     the Design Manager.
#
#   Change History :
#     Date      Who                            What
#     --------  -----------------------------  ------------------------------------------
#     08-13-91  MGC                            FCS release
#     11-22-93  MGC                            Corrected AMPLE_PATH and MGC_TYPE_REGSITRY
#                                              handling.  Eliminated need for dme.startup file.
#     03-23-94  MGC                            Enhanced AMPLE_PATH handling.
#
#
#
case "$MGC_HOME" in
 "") echo "The environment variable MGC_HOME is null or not set.">&2
    if [ -s /idea/bin/set_mgc_env ]; then
        echo "There is an MGC software tree at /idea; setting MGC_HOME to /idea.">&2
        MGC_HOME="/idea"
        export MGC_HOME
    else
        echo "Please set MGC_HOME to the location of the MGC software tree.">&2
        exit 1
    fi
 ;;
 *) if [ ! -s $MGC_HOME/bin/set_mgc_env ]; then
        echo "MGC_HOME is set to $MGC_HOME, which is not a valid MGC software tree.">&2
        echo "Please set MGC_HOME to the location of the MGC software tree.">&2
        exit 1
    fi
 ;;
esac

## SRP @ MGC 5/5/94 next line needs to be sourced
. $MGC_HOME/bin/set_mgc_env

MAX2_AMPLE_PATH="`$MGC_HOME/bin/get_hard_name -s '$MAX2_MENTOR/userware/default'`"
if [ $? -ne 0 ]; then
    echo "Error: Can not determine value of \$MAX2_MENTOR.  Should be set to /usr/maxplus2/mentor/max2"
    exit 1
else
    export MAX2_AMPLE_PATH
fi
## SRP @ MGC 5/5/94 next line paths were reordered
AMPLE_PATH=$AMPLE_PATH:$MAX2_AMPLE_PATH; export AMPLE_PATH

# TYPE_REGISTRY=$MAX2_MENTOR'/max2.rgy'
# export TYPE_REGISTRY

MAX2_TYPE_REGISTRY="`$MGC_HOME/bin/get_hard_name -s '$MAX2_MENTOR/max2.rgy'`"
if [ $? -ne 0 ]; then
    echo "Error: Can not determine value of \$MAX2_MENTOR.  Should be set to /usr/maxplus2/mentor/max2"
    exit 1
else
    export MAX2_TYPE_REGISTRY
fi
# SRP @ MGC 5/5/94 next line path were reordered.
MGC_TYPE_REGISTRY=$MGC_TYPE_REGISTRY:$MAX2_TYPE_REGISTRY; export MGC_TYPE_REGISTRY

##max2_toolbox_path="`$MGC_HOME/bin/get_hard_name -s '$MAX2_MENTOR/.toolbox'`"
dmgr_cmd="`$MGC_HOME/bin/resolve_mgc_path '$MGC_HOME/bin/dmgr'`"
#$dmgr_cmd $1
# Set up the path to Altera toolbox path; otherwise, the Altera toolbox
# won't be shown without displaying toolbox window during dmgr startup
$dmgr_cmd $1 <<!
  max2_toolbox();
!

